package com.xj0927.cloud.controller;

import cn.hutool.core.util.IdUtil;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.xj0927.cloud.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;


/**
 * @Author: xj0927
 * @Description:
 * @Date Created in 2020-10-30 9:04
 * @Modified By:
 */
@RestController
@Slf4j
public class PaymentController {
    @Autowired
    private PaymentService paymentService;

    //运行正常情况
    @GetMapping("/payment/hystrix/ok/{id}")
    public String payment_ok(@PathVariable Integer id){
        String result = paymentService.payment_ok(id);
        log.info("****" + result);
        return result;
    }
    //超时情况
    @GetMapping("/payment/hystrix/outTime/{id}")
    public String payment_outTime(@PathVariable Integer id){
        String result = paymentService.payment_outTime(id);
        log.info("****" + result);
        return result;
    }

    //服务熔断
    @GetMapping("/payment/Hystrix/circuitBreaker/{id}")
    public String paymentCircuitBreaker(@PathVariable("id")Integer id){
        return paymentService.paymentCircuitBreaker(id);
    }

}
